﻿/*
 * 文件名称：
 * 程序员：wangyun
 * 创建时间：2008/09/08
 * 
 * 功能说明：在线留言管理系统  
 * 
 * 修改人员：
 * 
 * 修改日期：
 * 
 * 修改记录：
 */

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Whir.Common.WebHelper;

public partial class Whir_System_Module_Reply_ReplyInfo : System.Web.UI.Page
{
    protected int ItemID = 0;
    protected int TypeID = 0;
    protected string url = "";

    protected void Page_Load(object sender, EventArgs e)
    {
        RoleHelper.IsLogin();    //登录判断

        ItemID = NetRequest.GetQueryInt("ItemID");
        TypeID = NetRequest.GetQueryInt("TypeID");
        url = Server.UrlDecode(NetRequest.GetQueryString("url"));

        if (TypeID == 2)
        {
            btnSubmit.Visible = true;
            divReply.Visible = true;
        }
        else
        {
            btnSubmit.Visible = false;
            divReply.Visible = false;
        }

        if (!IsPostBack)
        {
            BindData();
        }
    }

    private void BindData()
    {
        Whir.BLL.Whir_Reply bll = new Whir.BLL.Whir_Reply();
        Whir.Model.Whir_Reply model = new Whir.Model.Whir_Reply();
        model = bll.GetModel(ItemID);

        if (model != null)
        {
            lbTitle.Text = model.Title;
            lbContent.Text = Server.HtmlEncode(model.Content);
            lbCreateDate.Text = model.CreateDate.ToString();
            lbName.Text = model.CreateUserName;
            lbEmail.Text = model.CreateUserEmail;
            lbCreateUserIP.Text = model.CreateUserIP;
            txtInfo_Content.Value = model.ReplyContent;
        }
    }

    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        Whir.BLL.Whir_Reply bll = new Whir.BLL.Whir_Reply();
        Whir.Model.Whir_Reply model = new Whir.Model.Whir_Reply();
        model = bll.GetModel(ItemID);

        model.ReplyDate = DateTime.Now;
        model.ReplyContent = this.txtInfo_Content.Value;
        model.IsReply = string.IsNullOrEmpty(model.ReplyContent) ? false : true;
        bll.Update(model);

        JsHelper.redirect(Page, "回复反馈信息成功",url);
    }
}
